﻿using Newtonsoft.Json;

namespace DB.SchemaSync.Library.Models
{
	public class Parameter
	{
		[JsonIgnore]
		public Module Module { get; set; }
		public string Name { get; set; }
		public string DataType { get; set; }
		public long MaxLength { get; set; }
		public int Scale { get; set; }
		public int Precision { get; set; }
		public string Default { get; set; }
		public bool IsOutput { get; set; }
		public int Position { get; set; }

		/// <summary>
		/// For SQL Server use
		/// </summary>
		public int ObjectId { get; set; }

		public override string ToString()
		{
			return $"{Name} {DataType}";
		}

		public override bool Equals(object obj)
		{
			var check = obj as Parameter;
			if (check != null)
			{
				return (check.Module.Equals(Module) && check.Name.ToLower().Equals(Name));
			}
			return false;
		}

		public override int GetHashCode()
		{
			return Module.GetHashCode() + Name.ToLower().GetHashCode();
		}
	}
}